/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.stateless.install;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Singleton;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import smary.ejb.entity.Rollen;

/**
 * Bereitet die Neuinstallation/Installation von Scrummary vor.
 * Legt momentan hauptsächlich die Rollen im Datenmodell an.
 * @author Alex
 */
@Singleton
public class ScrummaryInstallService implements ScrummaryInstallServiceLocal {

    @PersistenceContext
    EntityManager em;
    
    @Override
    public void install() {
        //Rollen Definieren
        List<Rollen> rollen = new ArrayList<Rollen>();
        rollen.add(new Rollen(Short.MIN_VALUE, "Admin"));
        rollen.add(new Rollen(Short.MIN_VALUE, "ScrumMaster"));
        rollen.add(new Rollen(Short.MIN_VALUE, "ProductOwner"));
        rollen.add(new Rollen(Short.MIN_VALUE, "QualityManagement"));
        rollen.add(new Rollen(Short.MIN_VALUE, "Developer"));
        
        for(Rollen rolle : rollen){
            em.merge(rolle);
        }
        
        //TODO : Installationsroutine
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
    
}
